<style>
</style>
<template>
    <div>
        <el-upload class="upload-demo" :action="action" :on-preview="handlePreview" :on-remove="handleRemove" :before-upload="beforeUpload"
            :before-remove="beforeRemove" multiple :file-list="fileList" name='myfiles' :data="data" :on-success="handleSuccess" :on-error="onError">
            <el-button size="small" type="primary">点击上传</el-button>
        </el-upload>
    </div>
</template>

<script>

    export default {
        props: {
            action:{
                type:String,
                required:true,
            },
            data: {
                type: Object,
                default(){
                    return {}
                },
            },
            isupload:{
                type: Boolean,
                default:true,
            }
        },
        computed: {

        },
        watch: {

        },
        data() {
            return {
                fileList: []
            }
        },
        methods: {
            handleRemove(file, fileList) {
                console.log(file, fileList);
            },
            handlePreview(file) {
                console.log(file);
            },
            beforeUpload(file) {
                console.log(this.data.version)
                if (!this.data.version){
                    return false;
                }
            },
            onError(err, file, fileLis){
                console.log(err)
            },
            beforeRemove(file, fileList) {
                return this.$confirm(`确定移除 ${file.name}？`);
            },
            handleSuccess(){
                this.$emit('update:isupload',true)
            }
        }
    }
</script>